import { showLoading } from '@app-nextmesh-env/nextmesh/components';
import { documentV2 } from '@app-nextmesh-env/nextmesh/domain';
import { nmAppErrorLog } from '@app-nextmesh/common/utils';
import AlertDialog from '../AlertDialog';

interface IProps {
  uuid: string;
  onOk: () => void;
  onClose: () => void;
}
export default function SimulationAlertDialog({ uuid, onOk, onClose }: IProps) {
  const doDelete = async () => {
    const hide = showLoading();
    try {
      await documentV2.deleteSimulation(uuid);
      onOk();
      onClose();
    } catch (error) {
      nmAppErrorLog('SimulationAlertDialog', error);
    } finally {
      hide();
    }
  };
  return (
    <AlertDialog
      alert='确定删除这个仿真吗？'
      primaryTitle='确定删除'
      onPrimaryClick={doDelete}
      onSecondaryClick={onClose}
    />
  );
}
